home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2190 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: sdrc.com!thor!scjones
  2. From: larry.jones@sdrc.com (Larry Jones)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Examples of using "volatile"?
  5. Date: 19 Jan 1996 18:45:55 GMT
  6. Organization: SDRC Engineering Services
  7. Distribution: world
  8. Message-ID: <4doot3$l0u@info1.sdrc.com>
  9. References: <4djoj2$mr1@post.gsfc.nasa.gov> <4dm91p$bsi@info.uah.edu> <4dnf7f$1sa@fountain.mindlink.net>
  10. NNTP-Posting-Host: thor.sdrc.com
  11. Originator: scjones@thor
  12.  
  13. In article <4dnf7f$1sa@fountain.mindlink.net>, genew@mindlink.bc.ca (Gene Wirchenko) writes:
  14. > gbacon@oreo (Greg Bacon) wrote:
  15. > >Basically, like most modifiers, volatile is a hint to the compiler
  16. > >that the value of i could change at any time, and not to take its
  17. > >value for granted.  Of course, the compiler could ignore you since
  18. > >it's only a hint, but that wouldn't be a very good compiler :)
  19. >      No, it wouldn't because it would be broken.  K&R2, used as a sub
  20. > for the Standard by those of us without $120 or so to spend on said
  21. > Standard, says on page 211 (in the indented portion at the bottom):
  22. >      "The purpose of volatile is to force an implementation to
  23. > suppress optimization that could otherwise occur."
  24. >      Note the word "force".
  25.  
  26. The problem with using K&R2 as a sub for the Standard is that K&R2 is
  27. not the Standard -- it sacrifices precision in order to make things
  28. easier to understand.  What Greg said is much closer to what the
  29. Standard says than what K&R2 says.  There are only a couple of
  30. situations where the Standard imposes specific semantics on volatile
  31. that a compiler must implement; if the implementor can ensure that those
  32. situations are handled correctly, the compiler is not broken.  Most
  33. people would expect a high-quality compiler to handle many more system-
  34. specific situations correctly as well, but that is strictly a quality of
  35. implementation issue, not a standards conformance issue.
  36. ----
  37. Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
  38. larry.jones@sdrc.com
  39. There's never enough time to do all the nothing you want. -- Calvin
  40.